package com.test.dubbo.consumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ImportResource;

import com.test.dubbo.app.exception.BusinessException;
import com.test.dubbo.app.model.UserDto;
import com.test.dubbo.app.service.HelloService;


@SpringBootApplication
@ImportResource(locations={"dubbo-context.xml"})
public class Application {
	
	public static void main(String[] args) throws Exception {
        ApplicationContext ctx = SpringApplication.run(Application.class, args);
        HelloService helloService = ctx.getBean(HelloService.class);
        long t1 = System.currentTimeMillis();
        UserDto userDto = new UserDto();
        userDto.setUsername("xxx");
        userDto.setPassword("password");
        userDto.setAge(100);
        try {
        	
        	for (int i = 0; i < 100000; i++) {
        		String result = helloService.hello(userDto);
        		if(i % 1000 == 0) {
        			long t2 = System.currentTimeMillis();
        			System.out.println("完成1k次请求，耗时" + (t2 -t1) + "ms");
        			t1 = System.currentTimeMillis();
        		}
			}
//        	System.out.println(result);
        }catch(BusinessException e) {
        	System.out.println(e.getMessage());
        }
    }

}
